<template>
  <div class="main">
    <div class="header">
      当前已设网点：
      <span class="blue">{{ initData.ssmName || '暂未设置网点' }}</span>
    </div>
    <div class="f-row" style="margin-bottom: 20px;">
      <div class="item f-row a-i-c">
        <span class="item-1 ">一口价价格</span>
        <el-input class="item-2" v-model="fixedPriceData.basicPrice" placeholder="请输入价格" size="medium"></el-input>
				<el-button class="item-3" type="primary" size="medium">保存</el-button>
      </div>
    </div>
    <!-- <c-table
      ref="cTable"
      selection
      hasBorder
      :size="size"
      :max-height="500"
      :loading="isLoading"
      :table-header="tableHeader"
      :table-list="tableList"
      :page-info="pageInfo"
      :table-inner-btns="tableInnerBtns"
      @change-pagination="changePagination"
      @single-handle="changeSingleHandle"
    >
      <template v-slot:header>
        <c-search :form-model="searchObj" :form-items="searchItems" @submit-form="searchSubmit" @reset-form="searchReset"></c-search>
      </template>
    </c-table> -->
    <div class="header" style="font-weight: bold;">按重计价列表：</div>
    <div class="f-col">
      <div class="item f-row a-i-c" v-for="(item, index) in weightPriceData" :key="index">
        <div class="f-row a-i-c" style="margin-right: 20px;">
					<span class="item-1">最小重量(KG)</span>
					<el-input class="item-2" v-model="item.minWeight" placeholder="请输入价格" size="medium"></el-input>
				</div>
				<div class="f-row a-i-c">
					<span class="item-1">最大重量(KG)</span>
					<el-input class="item-2" v-model="item.maxWeight" placeholder="请输入价格" size="medium"></el-input>
				</div>
				<el-button class="item-3" type="primary" size="medium">保存</el-button>
      </div>
			<span v-if="weightPriceData.length === 0">暂无数据</span>
    </div>
		<div class="header" style="font-weight: bold;">分账列表：</div>
    <c-table
		  ref="cTable"
		  selection
		  hasBorder
		  :size="size"
		  :max-height="500"
		  :loading="isLoading"
		  :table-header="tableHeader"
		  :table-list="tableList"
		  :page-info="pageInfo"
		  :table-inner-btns="tableInnerBtns"
		  @change-pagination="changePagination"
		  @single-handle="changeSingleHandle"
		>
		  <template v-slot:header>
		    <c-search :form-model="searchObj" :form-items="searchItems" @submit-form="searchSubmit" @reset-form="searchReset"></c-search>
		  </template>
		</c-table>
  </div>
</template>

<script>
import mixinTable from 'mixins/table'
// import utils from 'utils'
import { marketQueryFixedPriceApi, marketQueryWeightPriceApi, marketQueryMerchatParApi } from '@/api/marketApi'

export default {
  mixins: [mixinTable],
  props: {
    initData: {
      type: Object,
      default() {
        return []
      }
    }
  },
  data(vm) {
    return {
      ssmInfo: '',
      tableList: [],
      tableInnerBtns: [
				{
				  name: '编辑',
				  width: 100,
				  handle(row) {
				    const { carNumber } = row
				    vm.routerLink(`/vehicle/operate/review/${carNumber}`)
				  }
				}
			],
      tableHeader: [
        {
          label: '商家编号',
          prop: 'merchantId',
          fixed: true,
          // search: {
          //   type: 'input',
          //   prop: 'name'
          // },
          width: 150
        },
        {
          label: '状态',
          prop: 'type',
          width: 100,
          setColor: row => (row.status == 0 ? 'red' : ''),
          formatter: row => row.type === 1 ? '平台' : '商户'
          // search: {
          //   type: 'dict',
          //   optionsList: dictObj.disabledStatus
          // }
        },
        {
          label: '占比率',
          prop: 'proportion',
          width: 100
        }
      ],
      fixedPriceData: '',
			weightPriceData: [],
    }
  },
  created() {
    this.fetchData()
    this.getFixedPrice() //一口价列表
		this.getWeightPrice()   //按重计
		// this.getMerchatPar()  //分账列表
  },
  methods: {
    fetchData() {
      const { pageNo, pageSize } = this.pageInfo
      const { id } = this.initData
      this.isLoading = true
      marketQueryMerchatParApi({
        pageSize,
        pageNo,
        ssmId: id
      }).then(res => {
        this.isLoading = false
        if (res.code === 0) {
          console.log('174===', res)
          this.tableList = res.data.data
          this.pageInfo.totalNum = res.totalCount
        }
      })
    },
    getFixedPrice() {
      const { id } = this.initData
      marketQueryFixedPriceApi({
        ssmId: id
      }).then(res => {
        console.log('177===', res)
        this.fixedPriceData = res.data
      })
    },
		getWeightPrice(){
			const { id } = this.initData
			marketQueryWeightPriceApi({
				ssmId: id
			}).then(res=>{
				console.log('187===', res)
				this.weightPriceData = res.data
			})
		},
		getMerchatPar(){
			// marketQueryMerchatParApi({
			// 	pageSize
			// 	pageNo
			// 	ssmId
			// }).then(res=>{
				
			// })
		},
    changeSingleHandle(item) {
      this.ssmInfo = item
    }
  }
}
</script>
<style lang="less" scoped>
.main {
  .header {
    margin-bottom: 20px;
    font-size: 16px;
  }
}
.item {
	margin-bottom: 10px;
}
.item-1 {
  width: 130px;
  font-size: 16px;
}
.item-2 {
	width: 150px;
}
.item-3{margin-left: 20px;}
</style>
